import { TMDB_Movie } from '../types';
import { makeMoviePosterImgUrl } from '../utils';

// 定义组件的 props 类型
interface MovieCardProps {
  movie: TMDB_Movie;
}

const MovieCard: React.FC<MovieCardProps> = ({
  movie: { poster_path, title, vote_average, original_language, release_date },
}) => {
  return (
    <div className="movie-card">
      <img src={makeMoviePosterImgUrl(poster_path)} alt={title} />
      <div className="mt-4">
        <h3>{title}</h3>
        <div className="content">
          <div className="rating">
            <img src="star.svg" alt="Star Icon" />
            <span>{vote_average}</span>
          </div>
          <span>·</span>
          <div>{original_language.toLocaleUpperCase()}</div>
          <span>·</span>
          <div>{release_date.slice(0, 4)}</div>
        </div>
      </div>
    </div>
  );
};

export default MovieCard;
